package com.mohan.dlxj.service.impl;

import com.mohan.dlxj.common.JsonResult;
import com.mohan.dlxj.mapper.RoleMapper;
import com.mohan.dlxj.pojo.Pole;
import com.mohan.dlxj.pojo.RoleList;
import com.mohan.dlxj.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
  @Autowired
  private RoleMapper roleMapper;
  @Override
  public JsonResult getRoleList(long current, long limit) {
    JsonResult jsonResult = new JsonResult();
    jsonResult.setCode(0);
    jsonResult.setMsg("");

    current = limit * (current - 1);
    List<RoleList> list = roleMapper.selectRolePage(current, limit);
    jsonResult.setCount(roleMapper.selectRoleAll());//总条数
    jsonResult.setData(list);
    return jsonResult;
  }

  @Override
  public Integer getRoleAll() {
    Integer all = roleMapper.selectRoleAll();
    return all;
  }

  @Override
  public void updateRole(RoleList roleList) {
    roleMapper.updateRole(roleList);
  }

  @Override
  public void deleteRole(Integer id) {
    roleMapper.deleteRole(id);
  }

  @Override
  public void saveRole(RoleList roleList) {
    roleMapper.saveRole(roleList);
  }

  @Override
  public RoleList getRoleById(Integer id) {
    return roleMapper.getRoleById(id);
  }

}
